package com.wenwei.utils;

import android.content.Context;

import com.wenwei.bean.LoginBean;
import com.wenwei.parking.Constant;


/**
 * Created by Administrator on 2017/6/8.
 */
public class UserStringUtils {

    public static int getUserStats(Context mContext) {
        LoginBean ub = RogerSPUtils.getObject(mContext, Constant.SP_USER_LOGIN_RESULT, LoginBean.class);
        if (ub != null)
            return ub.getStatus();
        return 0;
    }

    public static String getUserPhone(Context mContext) {
        LoginBean ub = RogerSPUtils.getObject(mContext, Constant.SP_USER_LOGIN_RESULT, LoginBean.class);
        if (ub != null)
            return ub.getUsername();
        return "";
    }

    public static boolean isAdmin(Context mContext) {
        LoginBean ub = RogerSPUtils.getObject(mContext, Constant.SP_USER_LOGIN_RESULT, LoginBean.class);
        if (ub != null){
            if(ub.getAuthorities().equals("admin")){
                return true;
            }else {
                return false;
            }

        }else {
            return false;
        }

    }

    public static String getUserToken(Context mContext) {
        LoginBean ub = RogerSPUtils.getObject(mContext, Constant.SP_USER_LOGIN_RESULT, LoginBean.class);
        if (ub != null)
            return "Bearer " + ub.getRemember_token();
        return "";
    }

    public static int getUserId(Context mContext) {
        LoginBean ub = RogerSPUtils.getObject(mContext, Constant.SP_USER_LOGIN_RESULT, LoginBean.class);
        if (ub != null)
            return ub.getId();
        return 0;
    }

    public static boolean isLogin(Context context) {
        LoginBean ub = RogerSPUtils.getObject(context, Constant.SP_USER_LOGIN_RESULT, LoginBean.class);
        if (ub != null)
            return true;
        return false;
    }

}
